<%--
  Created by IntelliJ IDEA.
  User: RobertWei
  Date: 2021/8/12
  Time: 11:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <br>
    <br>
    <br>
    <hr>
    <p>角色分配</p>

    <form action="/permission/change" method="get">
        <ul>
            <c:forEach var="role" items="${roles}">

                <c:set var="flag" value="0"></c:set>

                <c:forEach var="hr" items="${data.hasRoles}">
                    <c:if test="${hr.rId == role.rId}">
                        <c:set var="flag" value="1"></c:set>
                    </c:if>
                </c:forEach>

                <c:if test="${flag == 1}">
                    <li><input checked type="checkbox" name="roles" value="${role.rId}"> ${role.rName} </li>
                </c:if>
                <c:if test="${flag != 1}">
                    <li><input type="checkbox" name="roles" value="${role.rId}"> ${role.rName} </li>
                </c:if>

                <c:set var="flag" value="0"></c:set>

            </c:forEach>
        </ul>

        <button type="submit" >赋权</button>
    </form>
</body>
</html>
